import 'package:flutter/material.dart';

//输入框
class InputTestRoute extends StatefulWidget {
  @override
  _InputTestRoute createState() => new _InputTestRoute();
}

class _InputTestRoute extends State<InputTestRoute> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("输入框"),
      ),
      body: Center(
          child: Column(
        children: <Widget>[
          TextField(
            keyboardType: TextInputType.number,
            textInputAction: TextInputAction.next,
            textAlign: TextAlign.center,
            obscureText: true,
            onChanged: (v) {
              print("onChanged=====:$v");
            },
          ),
          TextField(
            autofocus: true,
            decoration: InputDecoration(
                labelText: "用户名",
                hintText: "用户名或邮箱",
                prefixIcon: Icon(Icons.person)),
            onChanged: (v) {
              print("onChanged:$v");
            },
          ),
          TextField(
            decoration: InputDecoration(
              labelText: "密码",
              hintText: "您的登录密码",
              prefixIcon: Icon(Icons.lock),
              enabledBorder: UnderlineInputBorder(
                  borderSide: BorderSide(color: Colors.red)),
              //获得焦点下划线设为蓝色
              focusedBorder: UnderlineInputBorder(
                borderSide: BorderSide(color: Colors.blue),
              ),
            ),
            obscureText: true,
          ),
          Container(
            child: TextField(
                keyboardType: TextInputType.emailAddress,
                decoration: InputDecoration(
                    labelText: "Email",
                    hintText: "电子邮件地址",
                    prefixIcon: Icon(Icons.email),
                    border: InputBorder.none //隐藏下划线
                    )),
            decoration: BoxDecoration(
                // 下滑线浅灰色，宽度1像素
                border: Border(
                    bottom: BorderSide(color: Colors.grey[200], width: 1.0))),
          )
        ],
      )),
    );
  }
}
